package com.zhouxiaoge.内部类;

import java.util.Arrays;

/**
 * @author 周明阳
 * mail:gqzmy@outlook.com
 * 时间:2018-05-04 14:31
 */

public class StaticInnerClassTest {
    public static void main(String[] args) {
        double[] d = new double[20];
        for (int i = 0; i < d.length; i++) {
            d[i] = 100 * Math.random();
        }
        ArrayAlg.Pair p = ArrayAlg.minmax(d);
        System.out.println("min = " + p.getFirst());
        System.out.println("max = " + p.getSecond());
    }
}

class ArrayAlg {
    public static class Pair {
        private double first;
        private double second;

        public Pair(double first, double second) {
            this.first = first;
            this.second = second;
        }

        public double getFirst() {
            return first;
        }

        public double getSecond() {
            return second;
        }
    }

    public static Pair minmax(double[] values) {
        double min = Double.MAX_VALUE;
        System.out.println(min);
        double max = Double.MIN_VALUE;
        System.out.println(max);
        System.out.println(Arrays.toString(values));
        for (double value : values) {
            if (min > value) {
                min = value;
            }
            if (max < value) {
                max = value;
            }
        }
        return new Pair(min, max);
    }
}
